package o;

import android.content.Context;
import com.huawei.appgallery.forum.section.actionbar.MenuLinearLayout;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import o.cab.a;

public class cad {
    private static cad ˏ;
    private HashMap<String, Class<? extends cae>> ˋ = new HashMap();

    public static synchronized cad ˋ() {
        cad o_cad;
        synchronized (cad.class) {
            if (ˏ == null) {
                ˏ = new cad();
            }
            o_cad = ˏ;
        }
        return o_cad;
    }

    private cad() {
        this.ˋ.put(KeyAndValue.NUMBER_01, cai.class);
        this.ˋ.put("02", cak.class);
        this.ˋ.put("03", cac.class);
    }

    public List<cae> ˋ(MenuLinearLayout menuLinearLayout, boolean z, int i, int i2) {
        if (menuLinearLayout == null) {
            return null;
        }
        menuLinearLayout.ˋ();
        String[] ˊ = ˊ(menuLinearLayout.getContext(), z, i);
        if (ˊ.length == 0) {
            return null;
        }
        List<cae> ˊ2 = ˊ(menuLinearLayout.getContext(), ˊ);
        for (cae o_cae : ˊ2) {
            o_cae.ˋ(i2);
            o_cae.ˎ(menuLinearLayout.getContext(), menuLinearLayout);
        }
        return ˊ2;
    }

    private List<cae> ˊ(Context context, String[] strArr) {
        List<cae> arrayList = new ArrayList();
        for (Object obj : strArr) {
            Class cls = (Class) this.ˋ.get(obj);
            if (cls != null) {
                try {
                    arrayList.add(cls.getConstructor(new Class[0]).newInstance(new Object[0]));
                } catch (Throwable e) {
                    bqx.ˊ("MenuFactory", "create menu error,", e);
                }
            }
        }
        return arrayList;
    }

    private String[] ˊ(Context context, boolean z, int i) {
        int i2;
        if (PackageUtils.HWGAMEBOX_PACKAGE_NAME.equals(context.getPackageName())) {
            if (z) {
                i2 = a.ॱ;
            } else {
                i2 = a.ʽ;
            }
        } else if (!"com.huawei.appmarket".equals(context.getPackageName())) {
            i2 = a.ˎ;
        } else if (!z) {
            i2 = a.ˊ;
        } else if (2 == i) {
            i2 = a.ˋ;
        } else {
            i2 = a.ˏ;
        }
        return context.getResources().getStringArray(i2);
    }
}
